package loads

import (
	"JVM/Jvmgo/GoToJVM/instructions/base"
	"JVM/Jvmgo/GoToJVM/runtimeData"
)

/*
这里写的是fload系列命令，
即将double类型数据从本地变量推送到操作数栈顶的字节码命令
*/
type DLOAD struct {
	base.Index8Instruction
}
type DLOAD_0 struct {
	base.NoOperandsInstruction
}
type DLOAD_1 struct {
	base.NoOperandsInstruction
}
type DLOAD_2 struct {
	base.NoOperandsInstruction
}
type DLOAD_3 struct {
	base.NoOperandsInstruction
}

func _dload(frame *runtimeData.Frame, index uint) {
	val := frame.LocalVars().GetDouble(index)
	frame.OperandStack().PushDouble(val)
}

func (self DLOAD) Execute(frame *runtimeData.Frame) {
	_aload(frame, uint(self.Index))
}
func (self DLOAD_0) Execute(frame *runtimeData.Frame) {
	_dload(frame, 0.0)
}
func (self DLOAD_1) Execute(frame *runtimeData.Frame) {
	_dload(frame, 1.0)
}
func (self DLOAD_2) Execute(frame *runtimeData.Frame) {
	_dload(frame, 2.0)
}
func (self DLOAD_3) Execute(frame *runtimeData.Frame) {
	_dload(frame, 3.0)
}
